package com.iotimc.attendancesystem.widget;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;

public class TestView extends android.support.v7.widget.AppCompatImageView {
    private Paint mPaint;
    private int mHeight = 0;



    public TestView(Context context) {
        this(context, null);
    }

    public TestView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public TestView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        mPaint = new Paint();
        mPaint.setStrokeWidth(5);
        mPaint.setColor(Color.parseColor("#00a2ff"));
        mPaint.setAntiAlias(true);
        mHeight=getWidth()/4;
    }



    @Override
    protected void onDraw(Canvas canvas) {
        for (int i = 1; i <= 2; i++) {
            canvas.save();
            canvas.rotate(360/2*i,getWidth()/2,getHeight()/2);

            canvas.drawLine(0,0,getWidth()/16,0 ,mPaint);
            canvas.drawLine(0,0,0,getWidth()/16 ,mPaint);

            canvas.drawLine(getWidth(),0,getWidth()-getWidth()/16,0 ,mPaint);
            canvas.drawLine(getWidth(),0,getWidth(),getWidth()/16 ,mPaint);

            canvas.restore();
        }

        mHeight += 1;

        canvas.drawLine(getWidth()/4,mHeight,getWidth()*3/4,mHeight ,mPaint);

        if (mHeight >= getHeight()*3/4) {
            mHeight = getWidth()/4;
        }

        postInvalidateDelayed(5);
    }
}